# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: Exp $

EAPI=2
inherit eutils autotools

INS_DIR="/opt/cern/alice/xrootd-vmss"

DESCRIPTION="ALICE ${PN} for xrootd"
SRC_URI="http://project-arda-dev.web.cern.ch/project-arda-dev/xrootd/tarballs/${XRD_PROG_NAME_DOWNLOAD_DIR}/${XRD_PROG_NAME_PREFIX}${XRD_PROG_NAME}-${XRD_PROG_VER}.tar.gz"

HOMEPAGE="http://project-arda-dev.web.cern.ch/project-arda-dev/xrootd/site/index.html"

SLOT="${PV}"
MY_SLOT="${PV}"
LICENSE="GPL-2"
KEYWORDS="~amd64 ~x86"

IUSE=""

RDEPEND="dev-libs/libxml2
  dev-util/pkgconfig
  >=sci-physics/eselect-xrootd-1.1.0
  =sci-physics/xrootd-${XROOTD_VER}
  ${XRD_DEPEND}"

CDEPEND="${RDEPEND}"

DEPEND="${CDEPEND}"

S="${WORKDIR}/${XRD_PROG_NAME_PREFIX}${XRD_PROG_NAME}-${XRD_PROG_VER}"
src_unpack() {
  unpack ${A}
  cd "${S}"
  eautoreconf
}

xrootd-vmss-src_configure_simple() {
  ./configure \
  --prefix=${INS_DIR}/${PV} \
  || die "configure failed"
}

xrootd-vmss-src_configure_xrootd() {
  ./configure \
  --prefix=${INS_DIR}/${PV} \
  --with-xrootd-location=$XROOTD_DIR/${XROOTD_VER} \
  || die "configure failed"
}

xrootd-vmss-src_configure_xrootd_alien() {
  ./configure \
  --prefix=${INS_DIR}/${MY_SLOT} \
	--with-certificate-directory=${D}/${INS_DIR}/${MY_SLOT}/share \
  --with-xrootd-location=$XROOTD_DIR/${XROOTD_VER} \
  || die "configure failed"
}

xrootd-vmss-src_configure_tokenauthz() {
  ./configure \
  --prefix=${INS_DIR}/${PV} \
  --with-xrootd-location=$XROOTD_DIR/${XROOTD_VER} \
  --with-tkauthz-incdir=${INS_DIR}/${PV}/include \
  --with-tkauthz-libdir=${INS_DIR}/${PV}/lib \
  || die "configure failed"
}

xrootd-vmss-src_configure_apmon() {
  ./configure \
  --prefix=${INS_DIR}/${PV} \
  --with-xrootd-location=$XROOTD_DIR/${XROOTD_VER} \
  --with-apmon-location=/usr/local \
  || die "configure failed"
}

src_compile() {
  emake OPT="${CFLAGS}" F77OPT="${FFLAGS}" || die "emake failed"
}


src_install() {
  emake DESTDIR="${D}" install || die "emake install failed"
}
